﻿<%@ Page Title="ErrorLog" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ErrorLog.aspx.cs" Inherits="Testify.Tools.ErrorLog" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

   <asp:SqlDataSource ID="sqlErrorLog" runat="server"
                      ConnectionString="<%$ ConnectionStrings:Singularity %>" 
                      ProviderName="<%$ ConnectionStrings:Singularity.ProviderName %>"
                      SelectCommand="SELECT Page_Name, error_msg, error_stacktrace, error_time
                                       FROM error_log
                                      WHERE upper(page_name) like (NVL(upper(:page_name), '%'))
                                      ORDER by error_time desc">
      <SelectParameters>
         <asp:ControlParameter ControlID="ddlPages" Name="page_name" 
            PropertyName="SelectedValue" />
      </SelectParameters>
   </asp:SqlDataSource>

   <asp:SqlDataSource ID="sqlPages" runat="server" 
                      ConnectionString="<%$ ConnectionStrings:Singularity %>"
                      ProviderName="<%$ ConnectionStrings:Singularity.ProviderName %>" 
                      SelectCommand="SELECT 'Sort By' as Name, '%' as page_name from dual
                                      UNION SELECT page_name AS Name, page_name
                                              FROM singularity.security
                                      WHERE page_name is not NULL
                                        AND security.permission_level &lt;= :UserPermission
                                      ORDER BY page_name">
      <SelectParameters>
         <asp:SessionParameter DefaultValue="0" Name="UserPermission" SessionField="UserPermission" />
      </SelectParameters>
   </asp:SqlDataSource>

   <div style="float:left; margin-left:20px;margin-right:20px;">
   <asp:DropDownList ID="ddlPages" runat="server" DataSourceID="sqlPages" DataTextField="Name" DataValueField="page_name" AutoPostBack="true" />
   <br /><br />
   <asp:UpdatePanel ID="updatePanel1" runat="server">
   <ContentTemplate>
   <asp:GridView ID="gdvErrorLog" EmptyDataText="There are no errors for this page." runat="server" 
                 AutoGenerateColumns="false" DataSourceID="sqlErrorLog" PageSize="100" AllowPaging="true">
      
      <Columns>
         <asp:BoundField DataField="error_time" HeaderText="Error Time" SortExpression="error_date" />
         <asp:BoundField DataField="page_name" HeaderText="Page Name" SortExpression="error_date" />

         <asp:TemplateField HeaderText="Error Message">
            <ItemTemplate>
               <asp:Label ID="lblExpand" runat="server" Text="Expand/Collapse" />
               <asp:Panel ID="pnlErrorMessage" runat="server" >
                  <asp:TextBox ID="txtErrorMessage" ReadOnly="true"  runat="server" Wrap="true" Width="800px" Rows="5" Text='<%# Eval("error_msg") %>' TextMode="MultiLine" />
               </asp:Panel>
               <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"
                  CollapsedSize="25"
                  CollapseControlID="lblExpand"
                  ExpandControlID="lblExpand"
                  TargetControlID="pnlErrorMessage"
                  TextLabelID="lblExpand"
                  CollapsedText="Expand"
                  ExpandedText="Collapse"
                  Collapsed="True" >
               </asp:CollapsiblePanelExtender>
            </ItemTemplate>
         </asp:TemplateField>

         <asp:TemplateField HeaderText="Error StackTrace">
            <ItemTemplate>
               <asp:Label ID="lblExpand2" runat="server" Text="Expand/Collapse"  />
               <asp:Panel ID="pnlStackTrace" runat="server" >
                  <asp:TextBox ID="txtStackTrace" ReadOnly="true"  runat="server" Wrap="true" Width="1000px" Height="550px" Text='<%# Bind("error_stacktrace") %>' TextMode="MultiLine" />
               </asp:Panel>
               <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender2" runat="server"
                  CollapseControlID="lblExpand2"
                  ExpandControlID="lblExpand2"
                  TargetControlID="pnlStackTrace"
                  TextLabelID="lblExpand2"
                  CollapsedText="Expand"
                  ExpandedText="Collapse"
                  Collapsed="True" >
               </asp:CollapsiblePanelExtender>
            </ItemTemplate>
         </asp:TemplateField>
      </Columns>
   
   </asp:GridView>
   </ContentTemplate>
   </asp:UpdatePanel>
   </div>

</asp:Content>

